package com.yowasa.xiuxian.engine.battle.buff;

import com.yowasa.xiuxian.annoations.Buff;
import com.yowasa.xiuxian.entity.bo.battle.BattleContent;
import com.yowasa.xiuxian.entity.bo.battle.BuffContent;
import com.yowasa.xiuxian.entity.bo.battle.TempUserBattle;
import com.yowasa.xiuxian.entity.bo.battle.UserBattleContent;
import com.yowasa.xiuxian.entity.bo.user.UserBattle;

@Buff(name = "灼魂")
public class ZhuoHunBuff implements BuffInterface {
    @Override
    public void effectBattleInfo(BuffContent content, TempUserBattle userBattle) {
        int restore = userBattle.getRestoreRate() - 30 * content.getNum();
        if (restore < 0) {
            userBattle.setRestoreRate(0);
        } else {
            userBattle.setRestoreRate(restore);
        }
    }

    @Override
    public void beforeBuffAction(UserBattleContent first, UserBattleContent second, BattleContent content) {
        BuffContent zhuoHun = first.getBuff().get("灼魂");
        int atk = second.getBattleInfo().getSpell();
        int dmg = (int) (atk * 0.1 * zhuoHun.getNum());
        first.getBattleInfo().setChp(first.getBattleInfo().getChp() - dmg);
        content.getMsgLog().add(first.getUserBO().getName() + "因灼魂咒失去了" + dmg + "点血");
    }
}
